<include file="../header" />
<body class="J_scroll_fixed">
<script type="text/javascript">
	$(function() {

		$("select[name='activityType']").change(function () {

					if($("select[name='activityType']").val() == 1) {
						$(".other-info").hide();
                        $(".own-info").show();
					} else if ($("select[name='activityType']").val() == 3){
						$(".own-info").hide();
						$(".other-info").hide();
                        $(".news-info").show();
					}else{
                        $(".own-info").hide();
                        $(".other-info").show();
                    }

		});

		if("{$info.activity_type}" == 1) {
            $(".other-info").hide();
			$(".own-info").show();
		} else if ("{$info.activity_type}" == 3){
            $(".own-info").hide();
            $(".other-info").hide();
            $(".news-info").show();
        }else{
            $(".own-info").hide();
            $(".other-info").show();
            $(".news-info").show();
        }

        $("select[name='activityPay']").change(function () {

            if($("select[name='activityPay']").val() == 1) {
                $(".price-info").show();
            } else {
                $(".price-info").hide();
            }

        });

        if("{$info.activity_pay}" == 1) {
            $(".price-info").show();
        } else {
            $(".price-info").hide();
        }

		var description = UE.getEditor('description',{
			initialFrameHeight:300,
			initialContent : "",
			serverUrl :'{:U("activity/ueditorUpload")}'
		});

		$("button#upload").click(function(){
			//上传文件
			$.ajaxFileUpload({
				url:"{:U('activity/uploadImage')}",//处理图片脚本
				secureuri :false,
				fileElementId :'fileToUpload',//file控件id
				dataType : 'json',
				success : function (data, status){
					$("input[name=titleImage]").val(data);
					$("img[name=preShow]").attr("src", data);
				},
				error: function(data, status, e){
					alert(e);
				}
			})
		});

		$("button.btn_submit").click(function() {

			$("input[name=description]").val(description.getContent());

			$("form").submit();

		})

	})

</script>
<script type="text/javascript"  src="__TMP__/assets/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript"  src="__TMP__/assets/js/ueditor/ueditor.all.min.js"></script>
<div class="wrap jj">
	<div class="common-form">
		<form method="post" class="form-horizontal J_ajaxForm" action="{:U('activity/editPost')}">
			<fieldset>
				<input type="hidden" name="id" value="{$info.activity_id}" />
				<div class="control-group">
					<label class="control-label">标题：</label>
					<div class="controls">
						<input type="text" class="input" name="title" value="{$info.title}">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">标题图片:</label>
					<div class="controls">
						<input id="fileToUpload" type="file" name="fileToUpload" style="width:170px;">
						<button type="button" class="btn btn-primary" id="upload">上传</button>
						<input type="hidden" name="titleImage" value="{$info.title_image}" />
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">图片预览:</label>
					<div class="controls">
						<img src="{$info.title_image}" name="preShow" style="width:400px;height:200px;" />
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">活动类型：</label>
					<div class="controls">
						{:getEnumSelectWidget($activityTypeEnum, 'activityType', $info['activity_type'], 0)}
					</div>
				</div>
				<div class="control-group other-info own-info">
					<label class="control-label">联系方式：</label>
					<div class="controls">
						<input type="text" class="input" name="contact" value="{$info.contact}">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">所属病症：</label>
					<div class="controls">
						<select name="categoryId">
							{:getCategorySelectOptionHtml($info['category_id'], 0)}
						</select>
					</div>
				</div>
				<div class="control-group other-info" style="display: none;">
					<label class="control-label">跳转链接：</label>
					<div class="controls">
						<input type="text" class="input" name="activityLink" value="{$info.activity_link}">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">开始时间：</label>
					<div class="controls">
						<input type="text" class="input J_datetime" name="beginTime" value="{$info.begin_time}">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">结束时间：</label>
					<div class="controls">
						<input type="text" class="input J_datetime" name="endTime" value="{$info.end_time}">
					</div>
				</div>
					<div class="control-group other-info own-info">
					<label class="control-label">活动地点：</label>
					<div class="controls">
						<input type="text" class="input" name="location" value="{$info.location}">
					</div>
				</div>
					<div class="control-group other-info own-info">
					<label class="control-label">是否付费：</label>
					<div class="controls">
						{:getEnumSelectWidget($activityPayEnum, 'activityPay', $info['activity_pay'], 0)}
					</div>
				</div>
				<div class="control-group price-info" style="display: none;">
					<label class="control-label">价格：</label>
					<div class="controls">
						<input type="text" class="input" name="price" value="{$info.price}">
					</div>
				</div>
					<div class="control-group other-info own-info">
					<label class="control-label">人数上限：</label>
					<div class="controls">
						<input type="text" class="input" name="upperLimit" value="{$info.upper_limit}">
					</div>
				</div>
					<div class="own-info news-info">
					<div class="control-group">
						<label class="control-label">详情描述：</label>
						<div class="controls">
							<input type="hidden" name="description" />
							<script type="text/plain" id="description" name="description">{$info.description}</script>
						</div>
					</div>
				</div>

			</fieldset>
			<div class="form-actions">
				<button type="button" class="btn btn-primary btn_submit">更新</button>
				<a class="btn" href="__URL__">返回</a>
			</div>
		</form>
	</div>
</div>
<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>